/*
 * Copyright 2011 The Rusted Roof, LLC.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package org.proteusframework.platformservice.persistence.packaging;

import org.proteusframework.platformservice.persistence.api.IPackagingVisitor;
import org.proteusframework.platformservice.persistence.base.AbstractPackageManager;

import java.io.File;
import java.io.IOException;

/**
 * Standard package manager that accepts an {@link IPackagingVisitor} and a <code>File</code>. The
 * visitation routine is <i>always</i> the same:
 * <ol>
 * <li>startVisit</li>
 * <li>visitProjectManager</li>
 * <li>visitMessageBeanManager</li>
 * <li>visitVFSManager</li>
 * <li>endVisit</li>
 * </ol>
 * <p/>
 * Therefore, there is rarely ever a need for an implementation to use anything other than the
 * <code>DefaultPackageManager</code>, since the true packaging logic will reside within the {@link IPackagingVisitor},
 * not the {@link org.proteusframework.platformservice.persistence.api.IPackageManager}.
 */
public final class DefaultPackageManager extends AbstractPackageManager
{
    /**
     * {@inheritDoc}
     */
    @Override
    public void acceptPackageVisitor(IPackagingVisitor visitor, File packageFile) throws IOException
    {
        visitor.startVisit(packageFile);

        visitor.visitProjectManager(getProjectManager());

        visitor.visitMessageBeanManager(getMessageBeanManager());

        visitor.visitVFSManager(getVfsManager());

        visitor.endVisit();
    }
}
